#include "Color/ColorSet.h"

using namespace std;

void ColorSet::AttachColor(const Color &c)
{
    if (c.importance == 0)
        return;
    auto cp = cm.find(c);
    if (cp == cm.end())
        cm.insert(make_pair(c, c.importance));
    else
        cm[c] += c.importance;
    size += c.importance;
}

std::list<Color> ColorSet::ToList() const
{
    auto cl = list<Color>();
    uint64_t pCount = 0;
    for (const auto& i : cm)
        cl.emplace_back(Color(i.first.r, i.first.g, i.first.b, i.first.a, i.second));
    return cl;
}
